from copy import deepcopy

def merge_dicts(*dicts):
    def merge_two_dicts(dict1, dict2):
        ret = deepcopy(dict1)
        for k, v in dict2.items():
            if k in ret and isinstance(ret[k], dict) and isinstance(v, dict):
                # If both values are dictionaries, merge them recursively
                ret[k] = merge_two_dicts(ret[k], v)
            else:
                # Otherwise, overwrite the value from dict2
                ret[k] = v
        return ret

    merged_result = {}
    for d in dicts:
        merged_result = merge_two_dicts(merged_result, d)
    
    return merged_result
